package cn.tedfu.controller;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//对比，请求参数的不同获取方式：get/restful
@RestController
@RequestMapping("ccc")
public class CarController2 {
    @RequestMapping("get")
    //1.普通的get方式获取请求参数
    //http://192.168.1.110:8080/ccc/get?id=1&name=张三&age=18
    public String get(Integer id,String name,Integer age){
        //return id+name+age;//直接吧结果展示在浏览器上
        return "{'id':"+"'"+id+"'}";
    }
    //2.restful 方式获取请求参数：通过{}绑定地址中参数的位置+通过注解获取{???}的值
    //http://localhost:8080/ccc/get2/1/张三/18
    @RequestMapping("get2/{id}/{name}/{age}")
    public void get2(@PathVariable Integer id,
                     @PathVariable String name,
                     @PathVariable Integer age
                    ){
        System.out.println(id);
        System.out.println(name);
        System.out.println(age);
    }
}
